import Ember from 'ember';

import InfiniteScroll from '../../infinite-scroll';

export default Ember.Controller.extend(InfiniteScroll,{
  infiniteContentPropertyName: "userBusinessMine",
  infiniteModelName: "user",
  infiniteContainerName:"userBusinessMineContainer",

  service_PageConstrut:Ember.inject.service("page-constructure"),
  mainController: Ember.inject.controller('business.mainpage'),

  isMobile: Ember.computed(function () {
    console.log("isMobile in:", this.get("global_curStatus").get("isMobile"));
    return this.get("global_curStatus").get("isMobile");
  }),//移动端
  userName: Ember.computed(function () {
    if (this.get('model.curUser').get('status') === 2 || this.get('model.curUser').get('status') === 3){
      return false;
    }
    return true;
  }).property('model.curUser.status'),
  userAll: Ember.computed(function () {
    if (this.get('model.curUser').get('status') === 2){
      return false;
    }
    return true;
  }).property('model.curUser.status'),
  statusFun: Ember.computed(function () {
    if (this.get('model.curUser').get('status') === 0){
      return "禁用";
    }else if (this.get('model.curUser').get('status') === 1) {
      return "申请认证";
    }else if (this.get('model.curUser').get('status') === 2) {
      return "已申请认证";
    } else if (this.get('model.curUser').get('status') === 3) {
      return "认证成功";
    }else if (this.get('model.curUser').get('status') === 4) {
      return " 认证失败";
    }
  }).property('model.curUser.status'),
  colorStatusFun:Ember.computed(function () {
    if (this.get('model.curUser').get('status') === 4){
      return false;
    }
    return true;
  }).property('model.curUser.status'),
  sex: Ember.computed(function() {
    if(this.get('model.curUser.sex')===2) {
      return '女';
    } return '男';
  }).property('model.curUser.sex'),
  sex2: Ember.computed(function() {
    console.log("this.get('model.curUser.sex'",this.get('model.curUser.sex'));
    if(this.get('model.curUser.sex')===2) {
      return true;
    } return false;
  }).property('model.curUser.sex'),
  sex1: Ember.computed(function() {
    console.log("this.get('model.curUser.sex'",this.get('model.curUser.sex'));
    if(this.get('model.curUser.sex')===1) {
      return true;
    } return false;
  }).property('model.curUser.sex'),

  actions:{
    cstagFun:function (menuLink,oriMenuCode) {
      this.get("mainController").switchMainPage(menuLink);
    },
    sexFun2:function(){
      var curUser=this.get('global_curStatus').getUser();
      this.store.findRecord("userPrivate",curUser.get("id")).then(function(userEnt){
        userEnt.set('sex',2);
        userEnt.save();
      });
      this.set('showAddContents',false);
    },
    sexFun1:function(){
      var curUser=this.get('global_curStatus').getUser();
      this.store.findRecord("userPrivate",curUser.get("id")).then(function(userEnt){
        userEnt.set('sex',1);
        userEnt.save();
      });
      this.set('showAddContents',false);
    },
    sexFun:function(){
      this.set('showAddContents',true);
    },
    certification:function (menuLink,oriMenuCode) {
      // var params = {source:amend};
      this.get("mainController").switchMainPage(menuLink);
    },
    //页面跳转
    modification:function (amend,menuLink,oriMenuCode) {
      // var _self=this;
      var params = {source:amend};
      this.get("mainController").switchMainPage(menuLink,params);
      // _self.get('target').send("reloadModel");
    },
  },
});
